Component({
    /**
     * 组件的属性列表
     */
    properties: {
        blockColor: {
            type: String,
            value: "#ffffff",
        },
        blockSize: {
            type: Number,
            value: 28,
        },
        backgroundColor: {
            type: String,
            value: "#e9e9e9"
        },
        activeColor: {
            type: String,
            value: "#1aad19",
        },
        // max,min,step,value,totalTop,totalHeight,disabled
        max: {
            type: Number,
            value: 100,
        },
        min: {
            type: Number,
            value: 0,
        },
        step: {
            type: Number,
            value: 1,
        },
        value: {
            type: Number,
            value: 0,
        },
        disabled: {
            type: Boolean,
            value: false,
        },
        showValue: {
            type: Boolean,
            value: false
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        totalTop: null,
        totalHeight: null,
        currentValue: 0,
    },

    ready() {
        this.queryHeight();
    },

    /**
     * 组件的方法列表
     */
    methods: {
        setCurrent: function (e) {
            this.setData({
                currentValue: e,
            });
        },
        queryHeight: function () {
            wx.createSelectorQuery()
                .in(this)
                .select(".slider-container")
                .boundingClientRect((res) => {
                    this.setData({
                        totalTop: res.top,
                        totalHeight: res.height,
                    });
                })
                .exec();
        },
    },
});